﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_category_modifyCategory : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int cid = 0;
        try
        {
            admin_category_category d = Context.Handler as admin_category_category;
            cid = Convert.ToInt32(d.Cid);
            if (cid != 0)
            {
                DB db = new DB();
                Category category = db.getCategory(cid);
                categoryName_cnTextBox.Text = category.Name_cn;
                categoryName_enTextBox.Text = category.Name_en;
                categoryDropdownList.SelectedValue = category.BelongTo.ToString();
                idLabel.Text = cid.ToString();
            }
        }
        catch (Exception)
        {

        }
    }
    protected void saveButton_Click(object sender, EventArgs e)
    {
        int cid = 0;
        try
        {
            cid = Convert.ToInt32(idLabel.Text);
        }catch(Exception)
        {
            throw new Exception("没有选择产品");
        }
         string name_cn = categoryName_cnTextBox.Text;
         string name_en = categoryName_enTextBox.Text;
         int belongTo = Convert.ToInt32(categoryDropdownList.SelectedValue);
         DB db = new DB();
         db.modifyCategory(cid,name_cn,name_en,belongTo);
    }
}
